using System;
using System.Collections.Generic;
using System.Text;

namespace RapidHDL.Fabric
{
    public class ResizeBlock : Block 
    {
        int iInputWidth;
        int iOutputWidth;

        public ResizeBlock(string psName, int piInputWidth, int piOutputWidth)
            : base(psName,"REG")
        {
            iInputWidth = piInputWidth;
            iOutputWidth = piOutputWidth;

            this.CreateInput("IN", piInputWidth);
            this.CreateOutput("OUT", piOutputWidth);
        }

        internal override void GenerateStructure()
        {
            NodeVector nvInput = ParentComponent.CreateNodeVector(Name + "_DATA_I", iInputWidth);
            NodeVector nvOutput = ParentComponent.CreateNodeVector(Name + "_DATA_O", iOutputWidth);
            Inputs["IN"].LinkNodeVector(nvInput);
            Outputs["OUT"].LinkNodeVector(nvOutput);
            nvOutput.Join(nvInput);
            if (iInputWidth < iOutputWidth)
                nvOutput[iInputWidth, iOutputWidth - 1].Join(0);
        }
 
    }
}
